﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeiTool.Common
{
    public static class ExtendMethod
    {  
        public static bool IsNullOrEmpty_Mei(this string Str)
        {
            return string.IsNullOrEmpty(Str);
        }

        public static bool IsNullOrWhiteSpace_Mei(this string Str)
        {
            return string.IsNullOrWhiteSpace(Str);
        }

        public static string DateTimeToString_yMdHms_Mei(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
        }

        public static bool SuperAny<T>(IEnumerable<T> values)
        {
            if (values == null)
            {
                return false;
            }
            return values.Any();
        }

        public static bool SuperAny<T>(IQueryable<T> values)
        {
            if (values == null)
            {
                return false;
            }
            return values.Any();
        }

        /// <summary>  
        /// 获取时间戳  
        /// </summary>  
        /// <returns></returns>  
        public static string GetTimeStampMilliseconds(this DateTime date)
        {
            TimeSpan ts = date.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalMilliseconds).ToString();
        }
    }
}
